package main

import (
	// "github.com/micro/go-log"

	// "github.com/micro/go-micro/web"
	"log"

	"go-micro.dev/v4/web"

	"gin_miaosa/zhiliao_web/middle_ware"
	all_router "gin_miaosa/zhiliao_web/router"

	"github.com/gin-gonic/gin"
)

func main() {

        router := gin.Default()
        // 使用全局中间件，跨域请求
        router.Use(middle_ware.CrosMiddleWare)

        // 注册路由组
        all_router.InitRouter(router)

        service := web.NewService(
                web.Name("zhiliao.web.web.zhiliao_web"),
                web.Version("latest"),
                web.Handler(router),
                web.Address(":8081"),
        )

	//     initialise service
        if err := service.Init(); err != nil {
                log.Fatal(err)
        }
        // service.Init(
        //         micro.Name("zhiliao.web.web.zhiliao_web"),
        //         micro.Version("latest"),
        //     )

	    // run service
        if err := service.Run(); err != nil {
                log.Fatal(err)
        }
}

// 发送邮件
// curl -X POST -d "email=1500876109@qq.com" http://localhost:8081/user/send_email

// INSERT INTO product_seckills (name, price, num, p_id, start_time, end_time, status, create_time) VALUES ('apple', 5.00, 5, 1, '2023-08-30 08:00:00', '2023-09-30 08:00:00', 0, '2023-09-3');


// SELECT * FROM `front_user`  WHERE (email = 'email2@example.com') AND (password = '1d4e8b12763757ef90fd62a03d989e5e')
// SELECT count(*) FROM `front_user`  WHERE `front_user`.`id` = 3 AND ((email = 'email2@example.com') AND (password = '1d4e8b12763757ef90fd62a03d989e5e'))